

from apiclient.discovery import build
def search(searchfor):
    service = build("customsearch", "v1",
            developerKey="AIzaSyB1KoWaQxP9_o--plv19-JYDevfdhKFzjs")
    res = service.cse().list(
      q=searchfor,
      cx='017576662512468239146:omuauf_lfve',
    ).execute()
    ret =  res['queries']['request'][0]['totalResults']
    return ret

# instead google you can write string to search for
val = search('google')
# val is returned value from search 
print val
